import { createApp } from 'vue'
import App from './App.vue'
import './style.css'
import router from './router'
import pinia from './stores'
import directive from './directive'
import './permission'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from "element-plus/dist/locale/zh-cn.mjs"
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import '@/assets/styles/index.scss'

//分页
import Pagination from "@/components/Pagination/index.vue"
//右侧工具栏
import RightToolbar from "@/components/RightToolbar/index.vue"
//字典标签组件
import DictTag from "@/components/DictTag/index.vue"

//重置表单
import {resetForm} from "@/utils"

//公共常量
import {CommonConstant} from "@/common/constant.ts"
//反馈组件
import {Message, MessageBox} from "@/plugins/feedback.ts"

//初始化字典
import initDict from "@/utils/dict.ts"


const app = createApp(App)

//全局组件挂载
app.component("Pagination", Pagination);
app.component("RightToolbar", RightToolbar);
app.component("DictTag", DictTag);

//全局方法挂载
app.config.globalProperties.resetForm = resetForm;
app.config.globalProperties.initDict = initDict;

// 全局变量挂载
app.config.globalProperties.$message = Message
app.config.globalProperties.$messageBox = MessageBox
app.config.globalProperties.$constant = CommonConstant

app.use(ElementPlus, {locale: zhCn})

app.use(pinia)
app.use(router)

//定义全局自定义指令
directive(app)

// 全局挂载和注册 element-plus 的所有 icon
app.config.globalProperties.$Icons = []
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.config.globalProperties.$Icons.push(key)
    app.component(key, component)
}

app.mount('#app')
